package com.sicau.smart_farmer.common;

import lombok.Getter;
import lombok.Setter;

/**
 * 返回视图
 * @author ttxxi
 */
@Getter
@Setter
public class ResultVO {
    private Integer code; //必须位0

    private String msg;

    private Object otherData;

    private Integer count ;//返回数据的条数

    private Object data;//[{},{}]






        public static ResultVO SUCCESS(Integer status, String msg, Object data){
            ResultVO resultVO = new ResultVO(0,"success");
            resultVO.setMsg(msg);
            resultVO.setCode(status);
            resultVO.setData(data);
            return resultVO;
        }

        public static ResultVO SUCCESS(Integer status, Object data){
            ResultVO resultVO = new ResultVO(0,"success");
        resultVO.setCode(status);
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO SUCCESS(Object data){
        ResultVO resultVO = new ResultVO(0,"success");
        resultVO.setData(data);
        return resultVO;
    }



    public static ResultVO FAILED(Integer status, String msg, Object data){
        ResultVO resultVO = new ResultVO(-1,"failed");
        resultVO.setMsg(msg);
        resultVO.setCode(status);
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO FAILED(Integer status, Object data){
        ResultVO resultVO = new ResultVO(-1,"failed");
        resultVO.setCode(status);
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO FAILED(Object data){
        ResultVO resultVO = new ResultVO(-1,"failed");
        resultVO.setData(data);
        return resultVO;
    }





    /*==================================================================*/





    public static ResultVO SUCCESS(Integer status, String msg, Object... data){
        ResultVO resultVO = new ResultVO(0,"success");
        resultVO.setMsg(msg);
        resultVO.setCode(status);
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO SUCCESS(Integer status, Object... data){
        ResultVO resultVO = new ResultVO(0,"success");
        resultVO.setCode(status);
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO SUCCESS(Object... data){
        ResultVO resultVO = new ResultVO(0,"success");
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO SUCCESS(String msg){
        ResultVO resultVO = new ResultVO(0,"success");
        resultVO.setMsg(msg);
        return resultVO;
    }


    public static ResultVO FAILED(Integer status, String msg, Object... data){
        ResultVO resultVO = new ResultVO(-1,"failed");
        resultVO.setMsg(msg);
        resultVO.setCode(status);
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO FAILED(Integer status, Object... data){
        ResultVO resultVO = new ResultVO(-1,"failed");
        resultVO.setCode(status);
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO FAILED(Object... data){
        ResultVO resultVO = new ResultVO(-1,"failed");
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO FAILED(String msg){
        ResultVO resultVO = new ResultVO(-1,"failed");
        resultVO.setMsg(msg);
        return resultVO;
    }

    private ResultVO(Integer status, String msg, Object data) {
        this.code = status;
        this.msg = msg;
        this.data = data;
    }

    private ResultVO(Integer status, String msg) {
        this.code = status;
        this.msg = msg;
    }


    public ResultVO setCount(Integer count) {
        this.count = count;
        return this;
    }

    public ResultVO setData(Object data) {
        this.data = data;
        return this;
    }

    public ResultVO setOtherData(Object otherData) {
        this.otherData = otherData;
        return this;
    }
}
